<?php

	function userHasRole($username, $role)
	{
		$result = false;
		try
		{
			connectDb("tictocwatches");
			global $dbLink;
			
			$queryString = "call sp_userHasRole('".mysqli_real_escape_string($dbLink,$username)."','".mysqli_real_escape_string($dbLink,$role)."')";
			//print_r($queryString);
			
			$resultPointer = mysqli_query($dbLink,$queryString);
			
			if($resultPointer)
			{
				while($resultRow = mysqli_fetch_assoc($resultPointer))
				{
					$resultSet = $resultRow;
					
					if( $resultSet["result"] == "TRUE")
					{
						$result = true;	
					}
					else
					{
						$result = false;
					}
				}
			}
			else
			{
				$queryError = mysqli_errno($dbLink);
				//print_r($queryError);
				if($queryError!=0)
				{
					parseDatabaseError($queryError);
				}
				$result = false;
			}
		}
		catch(Exception $ex)
		{
			throw new Exception($ex->getMessage());
		}
		
		return $result;
	}	

?>
